home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_077 / whydraco < prev   
Text File  |  1992-05-06  |  8KB  |  191 lines

  1.     What is Draco, Why Did I Write It and Why Is It Like It Is?
  2.  
  3.     I usually describe Draco (pronounced Dray-ko) as a "systems programming
  4. language". That means that it is a language which is suitable for what I
  5. think of as systems programming - writing operating systems, compilers,
  6. editors, databases, etc. This doesn't mean that it isn't suitable for other
  7. applications such as writing games, graphics programs, numerical programs,
  8. etc. It does mean that the language has all of the facilities needed for
  9. the former type of programming, such as bit operators, pointer
  10. manipulation, support for complex data structures, etc.
  11.  
  12.     What is different about Draco? I won't try to compare it with every
  13. other programming language in the world; instead I'll stick to two of the
  14. most popular ones for micros nowadays - C and Pascal. Draco has all of the
  15. facilities of C, except for bitfields and the macro preprocessor. Unlike C,
  16. and like Pascal, it is a strongly typed language. This means that it won't
  17. let you assign an integer to a pointer (unless you really insist). It is
  18. also not an expression language like C, thus it makes a quite strict
  19. distinction between statements like "a := 27" and expressions like "a +
  20. 27". Pascal is strongly typed, but lacks many of C's facilities - pointer
  21. manipulation, bit manipulation, standard separate compilation, conditional
  22. compilation, etc. I like to think that Draco combines the best features of
  23. both languages.
  24.  
  25.     Visually, Draco doesn't really resemble either language closely, but is
  26. a little closer to Pascal than C. It uses ':=' for assignment and '=' for
  27. comparison, like Pascal and unlike C. It's structure and union declarations
  28. are like those of C, however. As a simple comparison, here follows the same
  29. program, written in Pascal, C, and Draco:
  30.  
  31. Pascal:
  32.  
  33.     PROGRAM test(INPUT, OUTPUT);
  34.     VAR
  35.     i, j : INTEGER;
  36.     
  37.     BEGIN
  38.     FOR i := 0 TO 10 DO BEGIN
  39.         FOR j := 0 TO i DO
  40.         WRITE(j : 2, ' ');
  41.         WRITELN
  42.     END;
  43.     WRITELN("All done.")
  44.     END.
  45.  
  46. C:
  47.  
  48.     #include <stdio.h>
  49.  
  50.     main(argc, argv)
  51.     int argc;
  52.     char *argv[];
  53.     {
  54.     int i, j;
  55.     
  56.     for (i = 0; i <= 10; ++i) {
  57.         for (j = 0; j <= i; ++j)
  58.         printf("%2d ", j);
  59.         printf("\n");
  60.     }
  61.     printf("All done.\n");
  62.     }
  63.  
  64. Draco:
  65.  
  66.     proc main()void:
  67.     int i, j;
  68.     
  69.     for i from 0 upto 10 do
  70.         for j from 0 upto i do
  71.         write(j : 2, ' ');
  72.         od;
  73.         writeln();
  74.     od;
  75.     writeln("All done.");
  76.     corp;
  77.  
  78.     First, it's clear that the C program has lots of brackets, while the
  79. Pascal and Draco programs have lots of keywords. A significant difference,
  80. not very clear in this small example, is that Draco uses different keywords
  81. for each job, rather than relying on a single construct (the BEGIN - END or
  82. '{' - '}' block). I greatly prefer keywords, finding them easier on the
  83. eye. I also prefer languages in which the use of case (UPPER v.s. lower) is
  84. available for my own purposes, rather than having them equivalent as in
  85. most Pascals. Also, note that the Draco program uses 'upto' in the 'for'
  86. loops - this tells the compiler that the loop will be counting upwards;
  87. 'downto' is used for downward counting loops. C doesn't really have a
  88. semantically different 'for' loop - it's just a kind of shorthand for a
  89. 'while' loop.
  90.  
  91.     Some of the inadequacies of Pascal from my point of view are as
  92. follows:
  93.  
  94.     - no standard separate compilation
  95.     - no conditional compilation
  96.     - no general string mechanism
  97.     - no pointer manipulation
  98.     - no bit manipulation
  99.     - I HATE BEGIN and END!
  100.     - no signed/unsigned types
  101.     - limitations on function and argument types
  102.     - procedure calls don't use '()' - they look like variables
  103.     - no typed, named, constants
  104.     - no available, decent implementations (fast compilation, good
  105.         code, nice libraries, good error reporting)
  106.     - I/O semantics that are poor for interactive programs
  107.     - no file inclusion or module specification facility
  108.  
  109.     Some of the inadequacies of C from my point of view:
  110.  
  111.     - too many bloody brackets!
  112.     - horrible declaration syntax (just what is "char *(*p[])()"?)
  113.     - error prone conventions (how many times have YOU written '='
  114.         when you meant '=='?)
  115.     - non-portable I/O (if you don't believe this, take a look at the
  116.         open calls on CP/M or MS-DOS versions of C, where you get to
  117.         tell it what it's supposed to do with '\n')
  118.     - potential for extremely unreadable code (misuse of macros, etc.)
  119.     - slow compilers (as I've heard it, the reason that the original
  120.         UNIX C compiler for the PDP-11 generated assembler source was
  121.         so that the compiler writers didn't have to worry about long/
  122.         short branch optimization, since that was done by the
  123.         assembler. Producing assembler source is just plain slow. Those
  124.         who argue that they want to hand edit it to improve it are
  125.         crazy!)
  126.     - lack of much type checking (I prefer compilers that tell me about
  127.         my dumb mistakes. This is a lot better in the ANSI draft
  128.         version.)
  129.     - inefficient standard setup - passing everything as 16 bits on an
  130.         8 bit CPU isn't so hot (or 32 bits on a 16 bit one)
  131.     - stupid linkers - why add all that code I'm never calling?
  132.     - no built-in I/O - this makes even the simplest programs large
  133.     - no typed, named constants
  134.  
  135.     All of these issues have been addressed in the Draco language and
  136. tools. Just as important to me is the quality of the tools (compiler,
  137. linker, etc.) The Draco compiler goes from source code to relocatable,
  138. optimized machine code at a rate of about 2000 lines per minute on a 5 MHz
  139. 8080. Working from one 8" floppy disk, the entire compiler (about 10,000
  140. lines) can be rebuilt in under 10 minutes. No other compiler I've heard of
  141. for CP/M can do this (at least not and produce good code). The linker will
  142. link small programs in one quick pass, and won't load any code that isn't
  143. referenced by the program. A simple "hello there world" program is under
  144. 1000 bytes. The Amiga version of the compiler operates at about the same
  145. speed, and the linker I'm using (BLink) isn't bad, but doesn't selectively
  146. load like mine does.
  147.  
  148.     Another reason that these programs exist is that I LIKE writing
  149. compilers and stuff. I'm up to about seven compilers now, the latest of
  150. which is a C compiler that should meet the ANSI draft standard (it's a huge
  151. monster written in C, but at least I was paid to write it!)
  152.  
  153.     So I've written my very own personal compiler, that does things just
  154. the way I want; why should anyone else want to use it? Put simply, the
  155. Draco package (which includes the various libraries I've built up) is
  156. possibly the most effective way to produce compact, efficient code for CP/M
  157. systems. In the past couple of years, asside from fine tuning the compiler,
  158. I've written somewhere around 20,000 lines of Draco code, including the
  159. screen editor I'm typing this into, a complex graphic role-playing game,
  160. several CRT-oriented games for CP/M, ranging from the trivial to the quite
  161. complex, a database package, a text processor (with a friend), a modem
  162. program, etc. If you want to program a CP/M system, whether for fun, profit
  163. or whatever, and are willing to learn another language, then I feel that
  164. Draco is a valid choice. The Amiga version hasn't been used as much yet,
  165. but appears to be reasonably solid. I plan on bringing it up to the
  166. standard I set with the CP/M-80 version, but this will take time and a lot
  167. of work.
  168.  
  169.     To be fair, I will end this intro with a list of things that I find
  170. are lacking in this version of Draco:
  171.  
  172.     - essentially non-existant floating point support
  173.     - no proper modules (although Draco goes about half way to
  174.         providing a usable kind of module)
  175.     - no bit oriented type (I haven't yet fully convinced myself that
  176.         this is needed)
  177.     - error handling is considerably better than most C compilers I've
  178.         heard of, but it could still use some improvement
  179.     - object code can ALWAYS use improvement, but the improvements
  180.         that are left would either be difficult or of little actual
  181.         benefit and would probably make the compiler too big to fit on
  182.         standard CP/M systems. This isn't as much of a problem on the
  183.         Amiga, but I do plan on keeping the compiler small enough to
  184.         run well on a 512K machine.
  185.  
  186. and, of course
  187.  
  188.     - Draco is supported only by me, and available only on the systems
  189.         that I choose to put it on (currently CP/M-80 and Commodore
  190.         Amiga)
  191.